package com.cenntro.sca.demo;

import java.util.Properties;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;

import com.github.pagehelper.PageHelper;

@ServletComponentScan
@SpringBootApplication (scanBasePackages={"com.cenntro.sca.**"}) 
@MapperScan(basePackages = "com.cenntro.sca.**.mapper")
@ImportResource(locations = { "classpath:druid/druid-bean.xml" })
//@MapperScan(basePackages={"com.cenntro.common.*"})
public class PayMain {

	
	public static void main(String[] args) {
		SpringApplication.run(PayMain.class, args);
	}
	
	
	/**
	 * 分页组件
	 * 
	 * @return
	 */
	@Bean
	public PageHelper pageHelper() {
		PageHelper pageHelper = new PageHelper();
		Properties properties = new Properties();
		properties.setProperty("offsetAsPageNum", "true");  //RowBounds参数offset作为PageNum使用 
		properties.setProperty("rowBoundsWithCount", "true");  //RowBounds是否进行count查询
		properties.setProperty("reasonable", "false");        //分页合理化
		properties.setProperty("dialect", "Mysql"); // 配置postgresql数据库的方言支持Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库
//		properties.setProperty("pageSizeZero", "false");  //当设置为true的时候，如果pagesize设置为0（或RowBounds的limit=0），就不执行分页，返回全部结果
		//supportMethodsArguments  是否支持接口参数来传递分页参数，默认false
		pageHelper.setProperties(properties);
		return pageHelper;
	}

}
